<?php
/**
 * Created by PhpStorm.
 * User: wxy
 * Date: 2018/11/7
 * Time: 16:48
 */

namespace frontend\modules\common\logic;


use frontend\modules\common\models\dataTemplate\AudioTemp;
use frontend\modules\common\models\dataTemplate\BookTemp;
use frontend\modules\common\models\dataTemplate\DownloadTemp;
use frontend\modules\common\models\dataTemplate\PeriodicalTemp;
use frontend\modules\common\models\dataTemplate\PictureTemp;
use frontend\modules\common\models\dataTemplate\UserBranch;
use frontend\modules\common\models\dataTemplate\VideoTemp;
use yii\web\NotFoundHttpException;

class DownLoad
{
    /**
     * @param $type
     * @throws NotFoundHttpException
     * @throws \PHPExcel_Exception
     * @throws \PHPExcel_Writer_Exception
     */
    public function DownloadExcelTemp($type)
    {
        //BookTemp
        switch ($type) {
            case 'user'://用户
                $base = new UserBranch();
                break;
            case 1://图书
                $base = new BookTemp();
                break;
            case 2://期刊
                $base = new PeriodicalTemp();
                break;
            case 3://图片
                $base = new PictureTemp();
                break;
            case 4://音频
                $base = new AudioTemp();
                break;
            case 5://视频
                $base = new VideoTemp();
                break;
            default:
                throw new NotFoundHttpException('type invalid');
        }
        (new DownloadTemp($base))->down();
    }

}